
package edu.tongji.jiaowu.dao.jdbc;
 
import java.util.List;

import edu.tongji.jiaowu.dao.CodeDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.dao.jdbc.BaseDaoJdbc;

public class CodeDaoJdbc extends BaseDaoJdbc implements CodeDao {
	String tableName="T_CODE";
	String beanName="code";
	
	public CommonBean createCode(){
		CommonBean codes=this.createBean(tableName,beanName);
                return codes;		
	}
	
/*
	public CommonBean findCodes(String refid) {
		CommonBean codes=this.createCode();
		String sql="select * from T_CODE where refid=?";
		List data=this.getCommonDao().select(sql,new String[]{refid});
		codes.addData(data);
                return codes;
       }
*/
	public CommonBean findCodeById(String id) {
		CommonBean codes=this.createCode();
		String sql="select * from T_CODE where id=?";
		List data=this.getCommonDao().select(sql,new String[]{id});
		codes.addData(data);
    return codes;
  }
  
	public CommonBean findAllCodes() {
		CommonBean codes=this.createCode();
		String sql="select * from T_CODE ";
		List data=this.getCommonDao().select(sql,new String[]{});
		codes.addData(data);
    return codes;
  }
	public void insertCode(CommonBean codeBean){
		List data=codeBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchInsert(row,data,this.getIdGenerator());
	}
}

